<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.action.PostcheckReportAction"%>
<%@page import="java.util.LinkedHashMap"%>
<%@page import="com.shsh.safemanage.model.PostcheckMonthQualityReport.ShiyebuReport.ShiyebuReportCell"%>
<%@page import="com.shsh.safemanage.model.PostcheckMonthQualityReport.ShiyebuReport"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="java.util.Map"%>
<%@page import="com.shsh.safemanage.model.PostcheckMonthQualityReport"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.PostCheckDao"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.util.RequestUtil"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
{

Integer year = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_YEAR, 0);
Integer month = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_MONTH, 0);

PostCheckDao postcheckDao = DaoCreator.createPostCheckDao();

PostcheckMonthQualityReport report = postcheckDao.getMonthQualityReport(year, month);

if(report == null){
	int[] current = Util.getCurrentDate();
	if(year == current[0] && month == current[1]) {
		//current month
		PostcheckReportAction reportAction = ActionCreator.createPostcheckReportAction();
		report = reportAction.createQualityReport(year, month);
	}
}
%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 岗检汇总统计 &gt;&gt;<%=month %>月作业部岗检质量评价表
</div>
<div class="tt">《作业部岗检质量评价表》</div>
<div class="content" style="">
	<div style="margin-left: 10px">
	<span id="monthSelectSpan" style="margin-left: 10px;float:left;">	
	<%@include file="/postcheck_select/month_select_section2.jsp" %>
	</span>
	</div>
<%
if(report == null) {
%>
<div class="content" style="">
	<div style="float:left;padding-left:45%;padding-top:60px;font-size:14px;font-weight:bold;font-family:'微软雅黑','宋体';">未填报</div>
</div>
<%
	return;
}
%>

	
<%
Map<Long, Department1> shiyebuList = report.getShiyebuList();
Map<Long, PostcheckMonthQualityReport.ShiyebuReport> shiyebuReportMap = report.getShiyebuReportMap();
int tableWidth = 240 + shiyebuList.size() * 60;
%>
	<table border="1" width="<%=tableWidth+130%>" style="align:center; margin-left: 6px">
		<tr>
			<td colspan="4" style="text-align:center;" class="td3" width="240">
			单位
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
%>
			<td colspan="2" style="text-align:center;" class="td3" width="60">
			<%=Util.getDisplay(shiyebu.getDepartmentName(), "&nbsp;") %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			工作天数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
%>
			<td colspan="2" style="text-align:center;">
			<%=Util.getDisplay(report.getWorkingDay(), "&nbsp;") %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			参加岗检人数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());	
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport==null||shiyebuReport.getWorkerCount()==null?"&nbsp;":shiyebuReport.getWorkerCount()%>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			所属单元数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());	
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport==null||shiyebuReport.getUnitCount()==null?"&nbsp;":shiyebuReport.getUnitCount()%>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			应参加岗检人次数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());	
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport==null?"&nbsp;":Util.getDisplay(shiyebuReport.getMantimeNeed(),	 "&nbsp;") %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			实际参加岗检人次数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;" >
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getMantimeReal(), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			应岗检单元总数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getCheckUnitCountNeed(), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			实际岗检单元总数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getCheckUnitCountReal(), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			被查处“三违”现象次数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getIsSanweiCount(), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>

<%
Map<Long, PostCheck> postcheckList = report.getPostcheckList();
%>
		</tr>
		<tr>
			<td rowspan="<%=postcheckList.size() * 2 +2 %>" style="text-align:center;" class="td3" width="60">
			查出问题数
			</td>
			<td colspan="3" style="text-align:center;" class="td3" width="180">
			公司查出问题总数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getCorpProblemCount(), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>			
		</tr>
		<tr>
			<td colspan="3" style="text-align:center;" class="td3">
			作业部整改问题总数
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getIsClosedCount(), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>		
		</tr>
<%
for (PostCheck postcheck : postcheckList.values()) {
%>
		<tr>
			<td rowspan="2" style="text-align:center;" class="td3" width="60">
			<%=postcheck.getCheckName() %>
			</td>
			<td style="text-align:center;" class="td3" width="60">
			处室检查
			</td>
			<td style="text-align:center;" class="td3" width="60">
			检查扣分
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
	if (shiyebuReport != null ) {
		ShiyebuReportCell problemCountCell = shiyebuReport.getProblemCountMap().get(postcheck.getId());
%>
			<td style="text-align:center;" width="30">
				<%=problemCountCell!= null? Util.getDisplay(problemCountCell.getChushiCheckCount(), "&nbsp;"):"&nbsp;" %>
			</td>
			<td style="text-align:center;" width="30">
				<%=problemCountCell!= null? Util.getDisplay(problemCountCell.getChushiCheckGrade() == null ? null: Util.formatGrade(problemCountCell.getChushiCheckGrade()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
	} else {
%>
			<td style="text-align:center;" class="td3" width="30">
				&nbsp;
			</td>
			<td style="text-align:center;" class="td3" width="30">
				&nbsp;
			</td>
<%
	}
}
%>	
		</tr>
		<tr>
			<td style="text-align:center;" class="td3">
			作业部自查
			</td>
			<td style="text-align:center;" class="td3">
			检查扣分
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
	if (shiyebuReport != null ) {
		ShiyebuReportCell problemCountCell = shiyebuReport.getProblemCountMap().get(postcheck.getId());
%>
			<td style="text-align:center;">
				<%=problemCountCell!= null? Util.getDisplay(problemCountCell.getSelfCheckCount(), "&nbsp;"):"&nbsp;" %>
			</td>
			<td style="text-align:center;">
				<%=problemCountCell!= null? Util.getDisplay(problemCountCell.getSelfcheckedGrade()==null?null:Util.formatGrade(problemCountCell.getSelfcheckedGrade()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
	} else {
%>
			<td style="text-align:center;" class="td3">
				&nbsp;
			</td>
			<td style="text-align:center;" class="td3">
				&nbsp;
			</td>
<%
	}
}
%>
		</tr>
<%
}
%>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			日岗检计划完成率
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getDailyFinishRate() == null? null: Util.formatRate(shiyebuReport.getDailyFinishRate()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			日岗检工作参与度
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getDailyPartakeRate() == null? null: Util.formatRate(shiyebuReport.getDailyPartakeRate()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td rowspan="7" style="text-align:center;" class="td3">
			日岗检问题覆盖面
			</td>
			<td colspan="3" style="text-align:center;" class="td3">
			岗检问题整改率
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getClosedRate() == null? null: Util.formatRate(shiyebuReport.getClosedRate()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
		<tr>
			<td colspan="3" style="text-align:center;" class="td3">
			检查与自查总数对比
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getSlefCheckRate() == null? null: Util.formatRate(shiyebuReport.getSlefCheckRate()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>
		</tr>
<%
Map<Long, PostCheck> bigPostcheckMap = new LinkedHashMap<Long, PostCheck>();
for(Long bigPostcheckID: PostcheckMonthQualityReport.BIG_POSTCHECK_MAPPING.values()) {
	bigPostcheckMap.put(bigPostcheckID, report.getPostcheckList().get(bigPostcheckID));
}

for(PostCheck bigPostcheck : bigPostcheckMap.values()) {
%>
		<tr>
			<td colspan="3" style="text-align:center;" class="td3">
			<%=bigPostcheck.getCheckName() %>
			</td>
<%
	for (Department1 shiyebu: shiyebuList.values()) {
		ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
		if(shiyebuReport!=null) {
			Integer bigPostcheckRate = shiyebuReport.getCoverageMap().get(bigPostcheck.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=Util.getDisplay(bigPostcheckRate==null?null:Util.formatRate(bigPostcheckRate), "&nbsp;") %>
			</td>
<%
		} else {
			%>
			<td colspan="2" style="text-align:center;">
				&nbsp;
			</td>
<%	
		}
	}
%>
		</tr>
<%
}
%>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			 “三违”现象
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getSanwei()==null?null:Util.formatRate(shiyebuReport.getSanwei()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>			
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			岗检评价得分
			</td>
<%
for (Department1 shiyebu: shiyebuList.values()) {
	ShiyebuReport shiyebuReport = shiyebuReportMap.get(shiyebu.getId());
%>
			<td colspan="2" style="text-align:center;">
				<%=shiyebuReport!= null? Util.getDisplay(shiyebuReport.getAssessGrade()==null?null:Util.formatRate(shiyebuReport.getAssessGrade()), "&nbsp;"):"&nbsp;" %>
			</td>
<%
}
%>			
		</tr>
		<tr>
			<td colspan="4" style="text-align:center;" class="td3">
			汇总统计人
			</td>
			<td colspan="4" style="text-align:center;">
				<%=Util.getDisplay(report.getShiyebuWriteUserName(),"&nbsp;") %>
			</td>
			<td colspan="2" style="text-align:center;" class="td3">
			日期
			</td>
			<td colspan="4" style="text-align:center;">
				<%=Util.getDisplay(report.getShiyebuWriteTime()==null?null:Util.formatDate(report.getShiyebuWriteTime()),"&nbsp;") %>
			</td>
			<td colspan="<%=shiyebuList.size()*2-10 %>" style="text-align:center;">
				&nbsp;
			</td>
		</tr>
	</table>
</div>

<script type="text/javascript">
function changeReport(){
	var year = getElementValueByID('year');
	var month = getElementValueByID('month');
	loadPageSection(
			'<%=request.getContextPath()%>/postcheck/report/read_shiyebu_month_quality.jsp', 
			'mainContentDiv', 
			{
				year: year, 
				month: month 
			}, 
			true
	);
}
function selectYear(){
	changeReport();
}

function selectMonth(){
	changeReport();
}
</script>
<%
}
%>